<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    var map = {
        "avatar": "111",
        "food_ratings": [{
            "food_id": 694965364,
            "rate_name": "意式肉酱面",
            "rating": 2,
            "rating_text": "太差劲了啊",
            "sku_id": 312004533102,
            "tags": ["味道一般", "包装简陋", "价格贵"]
        }],
        "order_id": 1212057289458478299,
        "rated_at": "2017-09-18",
        "rating": 2,
        "rating_text": "太差劲了啊",
        "tags": ["配送慢"],
        "time_spent_desc": "40分钟送达",
        "username": "匿名用户"
    }
    // console.log(map.food_ratings[0].hasOwnProperty("food_id"))

    // hasOwnProperty  判断一个对象里面是否有某种属性
    Object.defineProperty(map, "avatar", {
        enumerable: false,     //是否被for in枚举
        writable: false,         //是否能修改
        configurable: false,     //是否能得删除属性 delete
        value:222               //属性的值
    })
    map.avatar = "123"
    delete map.avatar
    console.log(map.avatar)
    map.enumerable = false
    for (var sss in map) {
        console.log(sss)
    }

    // Object.preventExtensions(map)
    map.x = 0;
    console.log(Object.keys(map))
    Object.seal(map)
    delete map.x
    console.log(Object.keys(map))
    // console.log(map.x)

    Object.freeze(map)
    map.avatar = "new"
    console.log(map.avatar)
    </script>